//
//  DatePickerViewController.m
//  FMS
//
//  Created by Steven on 10/12/13.
//  Copyright (c) 2013 QGSVN. All rights reserved.
//

#import "DatePickerViewController.h"

@interface DatePickerViewController ()

@end

@implementation DatePickerViewController
@synthesize datePicker;
@synthesize delegate;
@synthesize paramSender;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil dateSelect:(NSDate *)date
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        datePicker.date = date;
        // Custom initialization
    }
    return self;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil dateSelect:(NSDate *)date paramSender:(id)sender {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        datePicker.date = date;
        // Custom initialization
        paramSender = sender;
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setContentSizeForViewInPopover:self.view.frame.size];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)btnCancelClick:(id)sender {
    if ([delegate respondsToSelector:@selector(didCancelSectDatePicker)]) {
        [delegate didCancelSectDatePicker];
    }
}

- (IBAction)btnSaveClick:(id)sender {
    if ([delegate respondsToSelector:@selector(didSelectDatePicker:)]) {
        [delegate didSelectDatePicker:datePicker.date];
    }
    else if([delegate respondsToSelector:@selector(didSelectDatePicker:paramSender:)]) {
        [delegate didSelectDatePicker:datePicker.date paramSender:paramSender];
    }
}
@end
